package com.zhijian.medical.controller;

import com.zhijian.medical.annotation.Response;
import com.zhijian.medical.entity.po.TTcProductAlarm;
import com.zhijian.medical.entity.vo.request.TTcProductAlarmSearchVo;
import com.zhijian.medical.entity.vo.response.TTcProductAlarmVo;
import com.zhijian.medical.service.TTcProductAlarmService;
import com.zhijian.medical.util.Page;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;

/**
 * 产品告警表 控制层
 *
 * @Author Auto Generator
 * @DateTime 2021-09-01 23:14:59
 * @version: 1.0.1
 */
@Slf4j
@Controller
@Api(tags = "产品告警表")
public class TcProductAlarmController {
    @Autowired
    private TTcProductAlarmService service;

    /**
     * 新增
     *
     * @param param
     * @return
     */
    @Response
    @PostMapping("/tc/product/alarm")
    @ApiOperation("新增")
    public boolean insert(@RequestBody TTcProductAlarm param) {
        log.info("{} - {}| insert info", this.getClass().getSimpleName(), param);
        return service.insert(param) != null;
    }

    /**
     * 删除
     *
     * @param id
     * @return
     */
    @Response
    @DeleteMapping("/tc/product/alarm/{id}")
    @ApiOperation("删除")
    public void delete(@PathVariable("id") Long id) {
        log.info("{} - {}| delete info", this.getClass().getSimpleName(), id);
        service.deleteById(id);
    }

    /**
     * 修改
     *
     * @param id
     * @param param
     * @return
     */
    @Response
    @PutMapping("/tc/product/alarm/{id}")
    @ApiOperation("修改")
    public boolean update(@PathVariable("id") Long id, @RequestBody TTcProductAlarm param) {
        log.info("{} - {}| update info, {}", this.getClass().getSimpleName(), id, param);
        param.setId(id);
        return service.update(param);
    }

    /**
     * 根据id查询
     *
     * @param id
     * @return
     */
    @Response
    @GetMapping("/tc/product/alarm/{id}")
    @ApiOperation("根据id查询")
    public TTcProductAlarmVo selectVoById(@PathVariable("id") Long id) {
        log.info("{} - {}| query info", this.getClass().getSimpleName(), id);
        return service.selectVoById(id);
    }

    /**
     * 分页查询
     *
     * @param tTcProductAlarmSearchVo
     * @return
     */
    @Response
    @PostMapping("/tc/product/alarm/page")
    @ApiOperation("分页查询")
    public Page<TTcProductAlarmVo> page(@RequestBody TTcProductAlarmSearchVo tTcProductAlarmSearchVo) {
        return service.selectPage(tTcProductAlarmSearchVo);
    }
}